<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateActivityPromotionEffect extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('activity_promotion_effect',['id'=>false,'comment'=>'活动推广效果汇总']);
        $table->addColumn('id', 'biginteger', ['limit' => 20, 'identity' => true, 'signed' => false])
            ->setPrimaryKey('id')
            ->addColumn('buyin_activity_id','biginteger',['limit'=>20,'default'=>0,'comment'=>'巨量百应活动id','signed'=>false])
            ->addColumn('product_id','string',['limit'=>32,'comment'=>'产品id'])
            ->addColumn('product_name','string',['limit'=>255,'comment'=>'产品标题'])
            ->addColumn('product_img','string',['limit'=>255,'comment'=>'产品主图'])
            ->addColumn('product_price','biginteger',['limit'=>20,'comment'=>'售价(分)'])
            ->addColumn('commission_rate','integer',['limit'=>3,'comment'=>'佣金率'])
            ->addColumn('service_rate','integer',['limit'=>3,'comment'=>'服务费率'])
            ->addColumn('order_pay_num','integer',['limit'=>10,'comment'=>'支付订单量','signed'=>false])
            ->addColumn('order_pay_amount','biginteger',['limit'=>20,'comment'=>'支付金额(分)','signed'=>false])
            ->addColumn('estimated_service_fee','biginteger',['limit'=>20,'comment'=>'预估服务费收入(分)','signed'=>false])
            ->addColumn('estimated_commission_fee','biginteger',['limit'=>20,'comment'=>'预估佣金收入(分)','signed'=>false])
            ->addColumn('create_time','datetime',['comment'=>'创建时间'])
            ->addColumn('update_time','datetime',['comment'=>'更新时间'])
            ->create();
    }
}
